"""
#! /usr/bin/env python
# -*- coding:utf-8 -*-
# __author__ = "SYLVANAS"
"""
import pymysql
from exercise import db_config


conn = pymysql.connect(**db_config.sql_conn_dict)
# 游标设置为字典型
cur = conn.cursor(cursor=pymysql.cursors.DictCursor)

cur.execute("select * from city")
# 获取10条数据
fetch_all = cur.fetchmany(10)
# 输出类型为字典
print('获得字典型数据', fetch_all)
# 可以通过迭代key获取数据
for row in fetch_all:
    print(row['ID'], row['Name'], row['CountryCode'], row['District'], row['Population'])

cur.close()
conn.close()


